<html>  
 <head>  
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  
 <title> </title> 
<style>
  #dv{
    width: 100px;
    height: 100px;
    background-color: royalblue;
  }
</style>
<body>
  <input type="button" value="隐藏" id="btn"/>
  <div id="dv"></div>
  <script>
    function my(id){
      return document.getElementById(id);
    }
    my("btn").onclick=function(){
      if (this.value =="隐藏") {
        my("dv").style.display="none";
        this.value="显示";
      } else if(this.value =="显示"){
        my("dv").style.display="block";
        this.value="隐藏";
      }
    }
  </script>
</body>
